package com.tiancheng.trade.commom.web.feign;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.commom.web.model.OrgBusinessDTO;
import com.tiancheng.trade.commom.web.model.request.MerchantChannelRequestDTO;
import com.tiancheng.trade.commom.web.model.request.OrderMerchantSettleReqVO;
import com.tiancheng.trade.commom.web.model.request.QueryOrderMerchantReqVO;
import com.tiancheng.trade.commom.web.model.request.QueryOrgBusinessReq;
import com.tiancheng.trade.commom.web.model.response.MerchantChannelResponseDTO;
import com.tiancheng.trade.commom.web.model.response.MerchantPaymentChannelBO;
import com.tiancheng.trade.commom.web.model.response.QueryOrderMerchantResVO;
import com.tiancheng.trade.commom.web.model.response.SettlementRuleResVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

/**
 * 商户Service接口
 */
@FeignClient(value = "trade-merchant",contextId = "trade-merchant-commom")
public interface MerchantFeignService {

    /**
     * 获取支付渠道，根据商品id
     *
     * @param goods
     * @return
     */
    @GetMapping(value = "/api/product/findPaymentChannelByProductCodes")
    Result findPayChannel(@RequestParam("list") String goods);


    /**
     * 获取支付渠道，根据商户编号
     *
     * @param merchantCodes
     * @return
     */
    @GetMapping(value = "/api/merchant/findPaymentChannelByMerchantCodes")
    Result<List<MerchantPaymentChannelBO>> findPaymentChannelByMerchantCodes(@RequestParam("list") String merchantCodes);

    /**
     * 根据应用id查询机构业务配置信息
     *
     * @param clientId 应用id
     * @return
     */
    @PostMapping(value = "/api/orgBusiness/queryOrgBusiness")
    Result<List<OrgBusinessDTO>> queryOrgBusiness(@RequestBody QueryOrgBusinessReq queryOrgBusinessReq);


    /**
     * 查询下单商户信息
     *
     * @param queryOrderMerchantReqVO
     * @return
     */
    @PostMapping(value = "/api/merchant/queryOrderMerchant")
    Result<List<QueryOrderMerchantResVO>> queryOrderMerchant(@RequestBody QueryOrderMerchantReqVO queryOrderMerchantReqVO);


    /**
     * 根据商户编码和支付渠道编码查询商户支付渠道
     *
     * @param merchantCode       商户编码
     * @param paymentChannelCode 渠道编码
     * @return
     */
    @GetMapping(value = "/api/merchant/findSubAppid")
    Result<MerchantChannelResponseDTO> findSubAppid(@RequestParam(name = "merchant_code") String merchantCode, @RequestParam(name = "payment_channel_code") String paymentChannelCode);

    /**
     * 根据商户编码和支付渠道编码查询商户支付渠道（批量）
     * @param list 商户编码和支付渠道编码
     * @return
     */
    @PostMapping("/api/merchant/findSubAppidList")
    Result<List<MerchantChannelResponseDTO>> findSubAppidList(@RequestBody List<MerchantChannelRequestDTO> list);

    /**
     * 查询机构的子商户，分账时用
     *
     * @param orgPaymentChannelId 支付机构id
     * @return
     */
    @PostMapping(value = "/api/merchant/queryOrgSubMerchant")
    Result<List<MerchantChannelResponseDTO>> queryOrgSubMerchant(@RequestBody() List<Long> orgPaymentChannelId);


    /**
     * 根据商户编码和支付渠道编码查询商户信息（批量）
     * @param list 商户编码和支付渠道编码
     * @return
     */
    @PostMapping("/api/merchant/listByMerchantCodeAndChannel")
    Result<List<MerchantChannelResponseDTO>> listByMerchantCodeAndChannel(@RequestBody List<MerchantChannelRequestDTO> list);

    /**
     * 根据交易中台商品编码批量查询清分规则
     *
     * @param merchantCodes String
     * @return
     */
    @PostMapping("/api/merchantSettleRule/findByMerchantCodes")
    Result<List<SettlementRuleResVO>> getRulesByMerchantCodes(@RequestBody Collection<String> merchantCodes);

    /**
     * 查询商户中心商户配置的清分规则
     * @param orderMerchantSettleReqVO
     * @return
     */
    @PostMapping("/api/merchantSettleRule/orderMerchantSettleRule")
    Result<List<SettlementRuleResVO>> queryOrderMerchantSettleRule(@RequestBody OrderMerchantSettleReqVO orderMerchantSettleReqVO);

    /**
     * 查询商户中心商户配置的清分规则
     * @param merchantRuleCodes 商户清分规则编码集合
     * @return
     */
    @PostMapping("/api/merchantSettleRule/findByRuleCodes")
    Result<List<SettlementRuleResVO>> queryOrderMerchantSettleRuleByMerchantRuleCods(@RequestBody Collection<String> merchantRuleCodes);

}